﻿using Opc.Ua;
using Opc.Ua.Server;
using SD.OpcServer.Host.Variables;
using System.Collections.Generic;

namespace SD.OpcServer.Host.Hosts
{
    /// <summary>
    /// OPC服务主机
    /// </summary>
    public class OpcServiceHost : StandardServer
    {
        /// <summary>
        /// 代理变量组列表
        /// </summary>
        private readonly ICollection<OpcVariableGroup> _variableGroups;

        /// <summary>
        /// 创建OPC服务主机构造器
        /// </summary>
        /// <param name="variableGroups">代理变量组列表</param>
        public OpcServiceHost(ICollection<OpcVariableGroup> variableGroups)
        {
            this._variableGroups = variableGroups;
        }

        /// <summary>
        /// 创建主节点管理器
        /// </summary>
        protected override MasterNodeManager CreateMasterNodeManager(IServerInternal server, ApplicationConfiguration configuration)
        {
            NodeManager nodeManager = new NodeManager(server, configuration, this._variableGroups);
            return new MasterNodeManager(server, configuration, null, nodeManager);
        }
    }
}
